/**
 * @file Contact.cs
 * @author Zane Mayo
 * @date 6/5/2009
 */

using System;

namespace MxitAPI {
	
	/**
	 * Holds the details of one contact. Can also hold some details about the logged in user
	 */
	public class Contact {
		
		public string ContactAddress { get; set; }
		public string NickName { get; set; }
		public Presence Presence { get; set; }
		public ContactType ContactType { get; set; }
		public Mood Mood { get; set; }
		private readonly int contactId;
		// Todo impliment a group for contacts
		//public ContactGroup Group { get; set; }
		public string Group { get; set; }
		
		private Contact( int contactId ) {
			this.contactId = contactId;
		}
		
		/**
		 * Creates a contact with data returned from the Mxit server
		 */ 
		public Contact( int contactId, RawContact rawContact ) : this ( contactId ) {
			ContactAddress = rawContact.ContactAddress;
			NickName = rawContact.NickName;
			Presence = rawContact.Presence;
			ContactType = rawContact.ContactType;
			Mood = rawContact.Mood;
			Group = rawContact.Group;
		}
		
		/**
		 * Creates the skeleton of a contact with only the ContactAddress from the mxit server
		 */ 
		public Contact( int contactId, string contactAddress ) : this ( contactId ) {
			ContactAddress = contactAddress;
			NickName = contactAddress;
			Presence = Presence.Offline;
			ContactType = ContactType.MXit;
			Mood = Mood.None;
			Group = "";
		}
		
		public int ContactId {
			get { return contactId; }
		}

        public void DoContactChanged() {
            Contacts.Instance.DoContactChanged( contactId );
        }
		
		public override string ToString() {
			string resultString = "";
			resultString += ContactAddress + " | ";
			resultString += NickName + " | ";
			resultString += Presence + " | ";
			resultString += ContactType + " | ";
			resultString += Mood + " | ";
			resultString += Group + " | ";
			return resultString;				
		}
		
		
	}
}
